package com.paradogs.framework.core.queue;

import com.baomidou.mybatisplus.extension.service.IService;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationTargetException;

/**
 * @author: yumi
 * @date: 2023/12/9  20:20
 * @Description: TODO
 */
@Slf4j
public class DBConsumer extends QueueConsumerThread<DBUpdatMsg> {

    /**
     * 保存到 DB，如果出现异常很危险
     * @param msg
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     */
    @Override
    public void handle(DBUpdatMsg msg) throws InvocationTargetException, IllegalAccessException {
        IService dao = msg.getDao();
        dao.saveOrUpdate(msg.getData());
        log.debug("保存 DB 成功：{}", msg.getData());
    }

    @Override
    public void loop() {
    }
}
